use std::net::{TcpListener, TcpStream};
use std::io::Read;

fn handle_client(mut stream: TcpStream) {
    // 获取客户端信息
    let mut buffer = [0;512];
    stream.read(&mut buffer).unwrap();

    println!("request:{}",String::from_utf8_lossy(&buffer[..]));
}

fn main() -> std::io::Result<()> {
    let listener = TcpListener::bind("127.0.0.1:80")?;

    // 接受连接并顺序处理
    for stream in listener.incoming() {
        handle_client(stream?);
    }
    Ok(())
}